package com.atguigu.gulimall.product.controller;

import com.atguigu.gmall.common.config.minio.service.FileUploadService;
import com.atguigu.gmall.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author nicc
 * @version 1.0
 * @className FileuploadController
 * @description TODO
 * @date 2022-09-28 19:35
 */

@RequestMapping("/admin/product")
@RestController
public class FileController {

    @Autowired
    private FileUploadService fileUploadService;


    @PostMapping("/fileUpload")
    public Result fileUpload(@RequestPart("file") MultipartFile file) throws Exception{

        System.out.println("文件名："+file.getOriginalFilename());
        System.out.println("文件大小："+file.getSize());

        String url = fileUploadService.upload(file);
        return Result.ok(url);
    }
}